# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=py3-libarchive-c
pkgver=5.1
pkgrel=1
pkgdesc="Python interface to libarchive"
url="https://github.com/Changaco/python-libarchive-c"
arch="noarch"
license="CC0-1.0"
depends="libarchive python3" # uses ffi
makedepends="python3-dev libarchive-dev py3-setuptools"
checkdepends="py3-pytest py3-mock"
subpackages="$pkgname-pyc"
source="python-libarchive-c-$pkgver.tar.gz::https://github.com/Changaco/python-libarchive-c/archive/$pkgver.tar.gz"
builddir="$srcdir/python-libarchive-c-$pkgver"

prepare() {
	default_prepare
	soname=$(scanelf --quiet --soname /usr/lib/libarchive.so | awk '{print $1}')
	sed -i -e "s/find_library('archive')/find_library('$soname')/" libarchive/ffi.py
}

build() {
	python3 setup.py build
}

check() {
	pytest
}

package() {
	python3 setup.py install --skip-build --root="$pkgdir"
}

sha512sums="
a2026aba3ef325f10e981e15e50de0435d7371642b0e6df8cd5ab64e76186b2a72297b32f429547e091fb799c9d0fa41be5a6824408c08f6c71585d59175d7a0  python-libarchive-c-5.1.tar.gz
"
